﻿;

CREATE TABLE `Billing` (
  `TransType` varchar(128) NOT NULL,
  `ID` int(11) NOT NULL AUTO_INCREMENT,
  `Operator` varchar(500) DEFAULT NULL,
  `LastOprator` varchar(500) DEFAULT NULL,
  `CompanyName` varchar(500) DEFAULT NULL,
  `CenterName` varchar(500) DEFAULT NULL,
  `DepartmentName` varchar(500) DEFAULT NULL,
  `StaffName` varchar(500) DEFAULT NULL,
  `CustomerName` varchar(500) DEFAULT NULL,
  `ProductName` varchar(500) DEFAULT NULL,
  `ProductGroupName` varchar(500) DEFAULT NULL,
  `SalesTypeName` varchar(500) DEFAULT NULL,
  `Remark` varchar(500) DEFAULT NULL,
  `CRM_OrderNo` varchar(500) DEFAULT NULL,
  `ContractNo` varchar(500) DEFAULT NULL,
  `IsNewCustomer` int(11) NOT NULL,
  `Amount` float(18,2) NOT NULL,
  `MenPiaoCount` float(18,2) NOT NULL DEFAULT '0',
  `TransDate` datetime NOT NULL,
  `LastModifyTime` datetime NOT NULL,
  `CreateTime` datetime NOT NULL,
  `IsConfirm` int(11) NOT NULL,
  `ConfirmBy` varchar(128) NULL,
  `IsAudit` int(11) NOT NULL,
  `AuditBy` varchar(128) NULL,
  `HasDeleted` int(11) NOT NULL DEFAULT '0',
  `DeleteBy` varchar(128) NULL,
  PRIMARY KEY (`ID`)
) ENGINE=InnoDB AUTO_INCREMENT=2 


;

CREATE TABLE `Center` (
  `ID` int(11) NOT NULL AUTO_INCREMENT,
  `Name` varchar(500) DEFAULT NULL,
  `Principal` varchar(500) DEFAULT NULL,
  `Remark` varchar(500) DEFAULT NULL,
  `CompanyName` varchar(500) DEFAULT NULL,
  `IsInactive` int(11) NOT NULL,
  PRIMARY KEY (`ID`)
) ENGINE=InnoDB 


;

CREATE TABLE `Company` (
  `ID` int(11) NOT NULL AUTO_INCREMENT,
  `Name` varchar(500) DEFAULT NULL,
  `Principal` varchar(500) DEFAULT NULL,
  `Remark` varchar(500) DEFAULT NULL,
  `IsInactive` int(11) NOT NULL,
  PRIMARY KEY (`ID`)
) ENGINE=InnoDB AUTO_INCREMENT=3 


;

CREATE TABLE `Customer` (
  `OID` varchar(128) NOT NULL,
  `Name` varchar(500) DEFAULT NULL,
  `Principal` varchar(500) DEFAULT NULL,
  `Remark` varchar(500) DEFAULT NULL,
  `CompanyOID` varchar(500) DEFAULT NULL,
  `CenterOID` varchar(500) DEFAULT NULL,
  `DepartmentOID` varchar(500) DEFAULT NULL,
  `StaffOID` varchar(500) DEFAULT NULL,
  `IsInactive` int(11) NOT NULL,
  PRIMARY KEY (`OID`)
) ENGINE=InnoDB 


;

CREATE TABLE `DateTargets` (
  `ID` int(11) NOT NULL AUTO_INCREMENT,
  `CompanyName` varchar(500) DEFAULT NULL,
  `CenterName` varchar(500) DEFAULT NULL,
  `DepartmentName` varchar(500) DEFAULT NULL,
  `Amount` float(18,2) NOT NULL,
  `BeginDate` datetime NOT NULL,
  `EndDate` datetime NOT NULL,
  PRIMARY KEY (`ID`)
) ENGINE=InnoDB 


;

CREATE TABLE `Department` (
  `ID` int(11) NOT NULL AUTO_INCREMENT,
  `Name` varchar(500) DEFAULT NULL,
  `Principal` varchar(500) DEFAULT NULL,
  `Remark` varchar(500) DEFAULT NULL,
  `CompanyName` varchar(500) DEFAULT NULL,
  `CenterName` varchar(500) DEFAULT NULL,
  `IsInactive` int(11) NOT NULL,
  PRIMARY KEY (`ID`)
) ENGINE=InnoDB 


;

CREATE TABLE `PrincipalGame` (
  `ID` int(11) NOT NULL AUTO_INCREMENT,
  `PrincipalA` varchar(500) DEFAULT NULL,
  `PrincipalB` varchar(500) DEFAULT NULL,
  PRIMARY KEY (`ID`)
) ENGINE=InnoDB 


;

CREATE TABLE `Product` (
  `ID` int(11) NOT NULL AUTO_INCREMENT,
  `Name` varchar(500) DEFAULT NULL,
  `Price` float(18,2) NOT NULL,
  `Principal` varchar(500) DEFAULT NULL,
  `Remark` varchar(500) DEFAULT NULL,
  `ProductGroupName` varchar(500) DEFAULT NULL,
  `IsInactive` int(11) NOT NULL,
  PRIMARY KEY (`ID`)
) ENGINE=InnoDB 


;

CREATE TABLE `ProductGroup` (
  `ID` int(11) NOT NULL AUTO_INCREMENT,
  `Name` varchar(500) DEFAULT NULL,
  `Principal` varchar(500) DEFAULT NULL,
  `Remark` varchar(500) DEFAULT NULL,
  `IsInactive` int(11) NOT NULL,
  PRIMARY KEY (`ID`)
) ENGINE=InnoDB 


;

CREATE TABLE `RoleAccess` (
  `OID` varchar(128) NOT NULL,
  `FormName` varchar(500) DEFAULT NULL,
  `ControlName` varchar(500) DEFAULT NULL,
  `Enabled` int(11) NOT NULL,
  `Visible` int(11) NOT NULL,
  `RoleName` varchar(128) NOT NULL,
  `IsInactive` int(11) NOT NULL,
  PRIMARY KEY (`OID`)
) ENGINE=InnoDB 


;

CREATE TABLE `SaleTarget` (
  `ID` int(11) NOT NULL AUTO_INCREMENT,
  `CompanyName` varchar(500) DEFAULT NULL,
  `CenterName` varchar(500) DEFAULT NULL,
  `DepartmentName` varchar(500) DEFAULT NULL,
  `Amount` float(18,2) NOT NULL,
  `Month` datetime NOT NULL,
  PRIMARY KEY (`ID`)
) ENGINE=InnoDB 


;

CREATE TABLE `Staff` (
  `ID` int(11) NOT NULL AUTO_INCREMENT,
  `Name` varchar(500) DEFAULT NULL,
  `Sex` int(11) NOT NULL,
  `EntryDate` datetime NOT NULL,
  `ExitDate` datetime NOT NULL,
  `Principal` varchar(500) DEFAULT NULL,
  `Remark` varchar(500) DEFAULT NULL,
  `CompanyName` varchar(500) DEFAULT NULL,
  `CenterName` varchar(500) DEFAULT NULL,
  `DepartmentName` varchar(500) DEFAULT NULL,
  `StaffLevel` varchar(500) DEFAULT NULL,
  `TargetAmount` varchar(500) DEFAULT NULL,
  `IsNormal` int(11) NOT NULL,
  `IsInactive` int(11) NOT NULL,
  `BirthDay` datetime NOT NULL DEFAULT '1900-01-01 00:00:00',
  PRIMARY KEY (`ID`)
) ENGINE=InnoDB 


;

CREATE TABLE `SysRole` (
  `RoleName` varchar(128) NOT NULL,
  `RoleDescription` varchar(500) DEFAULT NULL,
  `IsInactive` int(11) NOT NULL,
  PRIMARY KEY (`RoleName`)
) ENGINE=InnoDB 


;

CREATE TABLE `SysUser` (
  `UserName` varchar(128) NOT NULL,
  `UserPwd` varchar(256) DEFAULT NULL,
  `IsInactive` int(11) NOT NULL,
  `AllowAllCompany` int(11) NOT NULL DEFAULT '0',
  `CompanyName` varchar(500) DEFAULT NULL,
  PRIMARY KEY (`UserName`)
) ENGINE=InnoDB 


;

CREATE TABLE `SysUserRole` (
  `UserName` varchar(128) NOT NULL,
  `RoleName` varchar(128) NOT NULL,
  PRIMARY KEY (`UserName`,`RoleName`)
) ENGINE=InnoDB 


;

CREATE TABLE `UserReport` (
  `ID` int(11) NOT NULL AUTO_INCREMENT,
  `ReportName` varchar(256) DEFAULT NULL,
  `ReportSql` varchar(500) DEFAULT NULL,
  PRIMARY KEY (`ID`)
) ENGINE=InnoDB 


